<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Web Worker String Transfer Benchmark</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        .button-container {
            display: flex;
            justify-content: center;
            margin-bottom: 30px;
        }
        .control-group {
            display: flex;
            flex-direction: column;
        }
        label {
            font-weight: bold;
            margin-bottom: 5px;
            color: #555;
        }
        select, input, button {
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
        }
        button {
            background: #007bff;
            color: white;
            border: none;
            cursor: pointer;
            font-weight: bold;
            transition: background 0.3s;
        }
        button:hover {
            background: #0056b3;
        }
        button:disabled {
            background: #ccc;
            cursor: not-allowed;
        }
        .results {
            margin-top: 30px;
        }
        .result-section {
            background: #f8f9fa;
            padding: 20px;
            margin: 10px 0;
            border-radius: 5px;
            border-left: 4px solid #007bff;
        }
        .result-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid #eee;
        }
        .result-item:last-child {
            border-bottom: none;
        }
        .method-name {
            font-weight: bold;
            color: #333;
        }
        .time {
            font-family: monospace;
            font-size: 16px;
            color: #007bff;
        }
        .winner {
            background: #d4edda;
            border-left-color: #28a745;
        }
        .spinner {
            display: none;
            text-align: center;
            margin: 20px 0;
        }
        .spinner::after {
            content: '';
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid #007bff;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .stats {
            background: #e9ecef;
            padding: 15px;
            border-radius: 5px;
            margin-top: 20px;
        }
        .stat-item {
            display: flex;
            justify-content: space-between;
            margin: 5px 0;
        }
        .progress {
            width: 100%;
            height: 20px;
            background: #f0f0f0;
            border-radius: 10px;
            overflow: hidden;
            margin: 10px 0;
        }
        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #007bff, #0056b3);
            width: 0%;
            transition: width 0.3s ease;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🚀 Web Worker String Transfer Benchmark</h1>
        
        <div class="controls">
            <div class="control-group">
                <label for="testSize">Test Size:</label>
                <select id="testSize">
                    <option value="1048576">1 MB</option>
                    <option value="5242880">5 MB</option>
                    <option value="10485760" selected>10 MB</option>
                    <option value="52428800">50 MB</option>
                    <option value="104857600">100 MB</option>
                    <option value="209715200">200 MB</option>
                </select>
            </div>
            
            <div class="control-group">
                <label for="iterations">Iterations per method:</label>
                <input type="number" id="iterations" value="5" min="1" max="20">
            </div>
            
            <div class="control-group">
                <label for="stringType">String Content:</label>
                <select id="stringType">
                    <option value="random">Random ASCII</option>
                    <option value="unicode">Unicode (UTF-8)</option>
                    <option value="repeated">Repeated Pattern</option>
                </select>
            </div>
        </div>
        
        <div class="button-container">
            <button id="runBenchmark" onclick="runBenchmark()">Run Benchmark</button>
        </div>
        
        <div class="progress" id="progressContainer" style="display: none;">
            <div class="progress-bar" id="progressBar"></div>
        </div>
        
        <div class="spinner" id="spinner">
            <div>Running benchmark...</div>
        </div>
        
        <div class="results" id="results" style="display: none;">
            <h2>📊 Results</h2>
            <div id="resultContent"></div>
        </div>
    </div>

    <script type="module">
        import { initializeApp } from './src/main.ts';
        
        // Initialize the application
        initializeApp();
    </script>
</body>
</html>
